<template>
	
	<view>
		<view class="title-w-box" :style="{paddingTop: topSafe + 'px', opacity: opacity}">
		</view>
		<view id="past0" class="title-box" :style="{paddingTop: topSafe + 'px'}">
			<view class="main" :style="{color:opacity==1?'#000':'#fff'}">官方严选 安心租机</view>
		</view>
		
		<view class="yanxuan-page">
			<view class="topSafe" :style="'height:'+( topSafe || 0 )+'px'"></view>
			<view class="head-content">
				<view class="slogan"></view>
				<view class="mian-title">严选选机 省心租机</view>
				<view class="highlights">
					<view class="item">
						<image src="../../static/images/protect2.png" class="pic"></image>
						<text>顺丰包邮</text>
					</view>
					<view class="item">
						<image src="../../static/images/protect2.png" class="pic"></image>
						<text>赠送配件</text>
					</view>
					<view class="item">
						<image src="../../static/images/protect2.png" class="pic"></image>
						<text>安心租机</text>
					</view>
					<view class="item">
						<image src="../../static/images/protect2.png" class="pic"></image>
						<text>品质保障</text>
					</view>
				</view>
			</view>
			
			<view class="today-box">
				<view class="left-box">
					<view class="highlights">
						<view class="item">
							<image src="../../static/images/icon/protect.png" class="pic"></image>
							<text>苹果新款</text>
						</view>
						<view class="item">
							<image src="../../static/images/icon/protect.png" class="pic"></image>
							<text>超低租金</text>
						</view>
						<view class="item">
							<image src="../../static/images/icon/protect.png" class="pic"></image>
							<text>原装保障</text>
						</view>
						<view class="item">
							<image src="../../static/images/icon/protect.png" class="pic"></image>
							<text>全国联保</text>
						</view>
					</view>
					<view class="buy-btn" @click="toDetail(swiperList[currents - 1])">
						<text class="name">立即抢购</text>
						<text class="iconfont icon-xiangyou"></text>
					</view>
				</view>
				<view class="right-box">
					<swiper class="swiper-box" :autoplay="true" :interval="3000" :duration="1000" @change="swiperChange" :current="currents - 1">
						<swiper-item v-for="item in swiperList">
							<view class="swiper-item" @click="toDetail(swiperList[currents - 1])">
								<image :src="item.image"></image>
							</view>
						</swiper-item>
					</swiper>
					<view class="dots">
						<view class="dot" v-for="(item,index) in swiperList.length" :class="{'active':currents == index+1}"></view>
					</view>
		
				</view>
			</view>
			<view class="special-box">
				<view class="s-title">
					<image src="https://wap.yqjy8.vip/uploads/attach/2023/05/20230514/c7301f5518b2dab41995b7fcee6094b2.png"></image>
					<view class="sub">租前质检·租后保障</view>
				</view>
				<view class="s-list">
					<view 
						class="s-item" 
						v-for="(item, index) in list" 
						:key="index"
						@click="toDetail(item)"
					>
						<view class="pic-box">
							<view class="pic">
								<u--image 
									:showLoading="true" 
									:src="item.image" 
									width="300rpx" 
									height="270rpx" 
								></u--image>
							</view>
							<view class="day">{{ item.min_day }}天起租</view>
						</view>
						<view class="main-box">
							<view class="title m-ellipsis">
								<view class="news" v-if="item.dis_old == 100">全新</view>
								{{ item.store_name }}
								
							</view>
							<view class="tabs">
								<view class="tab">顺丰包邮</view>
								<!-- <view class="tab">租完归还</view> -->
							</view>
							<view class="price">¥<text>{{ item.min_day_price }}</text> <text class="note">/天</text></view>
						</view>
					</view>
				</view>
			</view>
			
			<view class="guarantee-box">
				<view class="gb-slogan">
					<view class="line left"></view>
					<view class="title">直租侠保障</view>
					<view class="line right"></view>
				</view>
				<view class="gb-list">
					<view class="gb-item">
						<view class="pic">
							<image src="../../static/images/icon-axz01.png"></image>
						</view>
						<view class="name">100%正品</view>
					</view>
					<view class="gb-item">
						<view class="pic">
							<image src="../../static/images/icon-axz02.png"></image>
						</view>
						<view class="name">假一赔三</view>
					</view>
					<view class="gb-item">
						<view class="pic">
							<image src="../../static/images/icon-axz03.png"></image>
						</view>
						<view class="name">原厂原装</view>
					</view>
					<view class="gb-item">
						<view class="pic">
							<image src="../../static/images/icon-axz04.png"></image>
						</view>
						<view class="name">联保保障</view>
					</view>
				</view>
			</view>
			
			<view class="bottom-search">
				<view class="name">上支付宝搜</view>
				<view class="set-box">
					<image src="../../static/images/icon/blue-search.png"></image>
					<text>直租侠</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { productYanxuan } from "@/api/brandHall.js"
	export default {
		components: {
		},
		data() {
			return {
				opacity: 0,
				topSafe: 0,
				currents: 1,
				swiperList: [],
				list: [], 
			}
		},
		onLoad() {
			// if(uni.getSystemInfoSync().safeAreaInsets){
			// 	this.topSafe = uni.getSystemInfoSync().safeAreaInsets.top
			// }
			
			uni.getSystemInfo({
				success: (e) => {
					this.topSafe = e.statusBarHeight //状态栏高度
				}
			})
			this.getProductYanxuan();
		},
		methods: {
			onPageScroll(res) {
				var that = this,
					scrollY = res.scrollTop;
				var opacity = scrollY / 200;
				opacity = opacity > 1 ? 1 : opacity;
				that.$set(that, 'opacity', opacity);
			},
			/* 获取严选数据 */
			getProductYanxuan() {
				productYanxuan().then(res => {
					console.log(res, "---res");
					this.list = res.data.list;
					this.swiperList = res.data.rec_list
				})
			},
			/* 跳转商品详情 */
			toDetail(item) {
				uni.navigateTo({
					url: `/pages/goods_details/index?id=${item.id}`
				})
			},
			swiperChange: function(e) {
				this.$set(this, 'currents', e.detail.current + 1);
			}
		}
	}
</script>

<style lang="scss">
	
	.title-w-box {
		position: fixed;
		top: 0;
		width: 100%;
		z-index: 277;
		display: flex;
		align-items: center;
		padding-left: 80rpx;
		background-color: #fff;
		height: 170rpx;
	}
	
	.title-box {
		position: fixed;
		top: 0;
		width: 100%;
		z-index: 277;
		display: flex;
		align-items: center;
		padding-left: 80rpx;
		height: 170rpx;
		.main {
			font-size: 32rpx;
			color: #fff;
		}
	
	}
	
	.yanxuan-page {
		padding: 0 24rpx 100rpx 24rpx;
		background: url("http://dwimg.yunwucloud.com/yanxuanBg.png");
		background-size: 100%;
		background-repeat: no-repeat;
		.head-content {
			.slogan {
				display: flex;
				height: 88rpx;
				align-items: center;
				font-size: 32rpx;
				font-weight: bold;
				color: #FFFFFF;
			}
			
			.mian-title {
				margin-top: 60rpx;
				height: 40rpx;
				line-height: 40rpx;
				font-size: 40rpx;
				color: #fff;
				font-weight: bold;
			}
			
			.highlights {
				padding-top: 16rpx;
				width: 50%;
				display: flex;
				flex-wrap: wrap;
				
				.item {
					margin-top: 32rpx;
					width: 154rpx;
					display: flex;
					align-items: center;
					
					.pic {
						margin-right: 8rpx;
						width: 26rpx;
						height: 26rpx;
					}
					
					text {
						font-size: 24rpx;
						color: #FFFFFF;
					}
				}
			}
		}
	
		.today-box {
			margin-top: 32rpx;
			background-image: url('https://wap.yqjy8.vip/uploads/attach/2023/05/20230513/f030a4dd4b64229d4e1dcd3749d263b0.png');
			background-repeat: no-repeat;
			background-size: 100%;
			width: 100%;
			height: 296rpx;
			padding: 24rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			
			.left-box {
				flex: 1;
				padding-top: 70rpx;
				
				.highlights {
					width: 100%;
					display: flex;
					flex-wrap: wrap;
					
					.item {
						margin-top: 24rpx;
						width: 154rpx;
						display: flex;
						align-items: center;
						
						.pic {
							margin-right: 8rpx;
							width: 26rpx;
							height: 26rpx;
						}
						
						text {
							font-size: 24rpx;
							color: #666666;
						}
					}
				}
			
				.buy-btn {
					margin-top: 24rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 170rpx;
					height: 56rpx;
					background: linear-gradient(90deg, #FF8533 0%, #FF3729 100%);
					border-radius: 28rpx;
					
					.name {
						font-size: 24rpx;
						font-weight: 400;
						color: #FFFFFF;
					}
					
					.iconfont {
						margin-left: 6rpx;
						font-size: 24rpx;
						color: #fff;
						transform: scale(0.9);
					}
				}
			}
		
			.right-box {
				background-image: url('https://wap.yqjy8.vip/uploads/attach/2023/05/20230513/a8ea6dc3e19b4898610d9b445ddbf143.png');
				background-repeat: no-repeat;
				background-size: 100%;
				width: 312rpx;
				height: 232rpx;
				position: relative;
				
				.swiper-box {
					height: 232rpx;
					
					swiper-item {
						display: flex;
						justify-content: center;
						align-items: center;
						
						image {
							width: 142rpx;
							height: 176rpx;
						}
					}
					
				}
				
				.dots {
					position: absolute;
					bottom: 16rpx;
					left: 0;
					display: flex;
					width: 100%;
					justify-content: center;
					
					.dot {
						margin: 0 4rpx;
						width: 6rpx;
						height: 6rpx;
						background: rgba(0,0,0,0.24);
						border-radius: 50%;
						
						&.active {
							background: #fff
						}
					}
				}
			}
		}
	
		.special-box {
			background-image: url('https://wap.yqjy8.vip/uploads/attach/2023/05/20230514/b5bb7c3957052fdc66a7555883cfeda9.png');
			background-repeat: no-repeat;
			background-size: 100%;
			width: 100%;
			
			
			.s-title {
				padding: 56rpx 24rpx 24rpx 24rpx;
				display: flex;
				align-items: center;
				
				image {
					width: 240rpx;
					height: 32rpx;
				}
				
				.sub {
					margin-left: 16rpx;
					padding-left: 16rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: #CC7439;
					border-left: 2rpx solid #CC7439;
					line-height: 24rpx;
				}
			}
		
			.s-list {
				padding: 0 24rpx 24rpx 24rpx;
				display: flex;
				justify-content: space-between;
				flex-wrap: wrap;
				background: #FFF3EB;
				border-radius: 0rpx 0rpx 16rpx 16rpx;
				
				.s-item {
					margin-top: 24rpx;
					width: 316rpx;
					background-color: #fff;
					border-radius: 8rpx;
					
					.pic-box {
						background-image: url('https://wap.yqjy8.vip/uploads/attach/2023/05/20230514/6b94e9790071b0b907321ff3757cfd3f.png');
						background-repeat: no-repeat;
						background-size: 100%;
						width: 316rpx;
						height: 316rpx;
						position: relative;
						
						.pic {
							position: absolute;
							top: 8rpx;
							left: 8rpx;
							z-index: 1;
							width: 300rpx;
							height: 270rpx;
							// background-color: #ccc;
							overflow: hidden;
							image {
								width: 300rpx;
								height: 270rpx;
							}
						}
						
						.day {
							position: absolute;
							left: 0;
							bottom: 0;
							z-index: 2;
							width: 100%;
							height: 44rpx;
							font-size: 24rpx;
							font-weight: bold;
							color: #FFFFFF;
							display: flex;
							align-items: center;
							justify-content: center;
						}
					}
					
					.main-box {
						margin-top: 18rpx;
						padding: 0 16rpx 28rpx 16rpx;
						
						.title {
							font-size: 28rpx;
							font-weight: bold;
							color: #1F1F1F;
							line-height: 44rpx;
							vertical-align: middle;
							
							.news {
								display: inline-block;
								margin-right: 4rpx;
								width: 64rpx;
								height: 40rpx;
								line-height: 40rpx;
								font-size: 24rpx;
								font-weight: bold;
								color: #FFFFFF;
								background: linear-gradient(180deg, #FF9D5C 0%, #FF7847 100%);
								border-radius: 20rpx;
								text-align: center;
							}
						}
					
						.price {
							margin-top: 24rpx;
							font-size: 28rpx;
							font-weight: bold;
							color: #FF1F2E;
							vertical-align: text-bottom;
							
							text {
								margin-left: 4rpx;
								font-size: 40rpx;
							}
							
							.note {
								margin-left: 8rpx;
								font-size: 24rpx;
								font-weight: 400;
								color: #FF1F2E;
							}
						}
					
						.tabs {
							margin-top: 12rpx;
							display: flex;
							
							.tab {
								margin-left: 8rpx;
								width: 104rpx;
								height: 32rpx;
								line-height: 32rpx;
								background: rgba(110,184,179,0.12);
								border-radius: 4rpx;
								font-size: 24rpx;
								color: #6EB8B3;
								text-align: center;
								
								&:first-child { margin-left: 0; }
							}
						}
					}
				}
			}
		}
	
		.guarantee-box {
			margin-top: 48rpx;
			
			.gb-slogan {
				display: flex;
				justify-content: center;
				align-items: center;
				
				.line {
					width: 160rpx;
					height: 2rpx;
					
					&.left { background: linear-gradient(90deg, rgba(204,204,204,0) 0%, #CCCCCC 100%); }
					&.right { background: linear-gradient(90deg, #CCCCCC 0%, rgba(204,204,204,0) 100%); }
				}
				
				.title {
					margin: 0 16rpx;
					font-size: 36rpx;
					font-weight: bold;
					color: #1F1F1F;
					letter-spacing: 2rpx;
				}
			}
		
			.gb-list {
				margin-top: 48rpx;
				display: flex;
				
				.gb-item {
					width: 25%;
					text-align: center;
					
					.pic {
						margin: 0 auto;
						width: 88rpx;
						height: 88rpx;
						
						image {
							width: 100%;
							height: 100%;
						}
					}
					
					.name {
						margin-top: 16rpx;
						font-size: 28rpx;
						font-weight: bold;
						color: #666666;
						line-height: 28rpx;
					}
				}
			}
		}
	
		.bottom-search {
			padding: 8rpx 8rpx 8rpx 24rpx;
			display: flex;
			align-items: center;
			margin-top: 48rpx;
			width: 100%;
			height: 88rpx;
			background: #297EFF;
			border-radius: 16rpx;
			
			.name {
				font-size: 28rpx;
				font-weight: bold;
				color: #FFFFFF;
			}
			
			.set-box {
				margin-left: 24rpx;
				padding: 0 24rpx;
				position: relative;
				flex: 1;
				height: 100%;
				background: #FFFFFF;
				border-radius: 8rpx;
				display: flex;
				align-items: center;
				
				image {
					width: 32rpx;
					height: 32rpx;
				}
				
				text {
					margin-left: 16rpx;
					font-size: 28rpx;
					font-weight: 400;
					color: #1F1F1F;
					letter-spacing: 2rpx;
				}
			}
		}
	}
</style>